package com.circle.interests.api.enums;

import lombok.Getter;

/**
 * @author zhou
 * @date 2021/1/15
 */
public enum InventoryTypeEnum {
    /**
     * 库存类型
     */
    UNLIMITED(1, "不限量"),
    LIMITED_NUMBER(2, "限量个数"),
    LIMITED_AMOUNT(3, "限量金额");

    @Getter
    private final Integer code;
    @Getter
    private final String info;

    InventoryTypeEnum(Integer code, String info) {
        this.code = code;
        this.info = info;
    }

    public static InventoryTypeEnum getByCode(Integer code) {
        return getByCode(code, null);
    }

    public static InventoryTypeEnum getByCode(Integer code, InventoryTypeEnum defaultValue) {
        for (InventoryTypeEnum e : InventoryTypeEnum.values()) {
            if (e.code.equals(code)) {
                return e;
            }
        }
        return defaultValue;
    }
}
